package cn.drenal.capcap.entity;

import cn.drenal.capcap.entity.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tangzc.autotable.annotation.*;
import com.tangzc.mpe.annotation.InsertFillTime;
import com.tangzc.mpe.annotation.InsertUpdateFillTime;
import com.tangzc.mpe.autotable.annotation.*;
import com.tangzc.mpe.processer.annotation.AutoDefine;
import com.tangzc.mpe.processer.annotation.AutoMapper;
import com.tangzc.mpe.processer.annotation.AutoRepository;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 浏览历史表
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper
@Table(comment = "浏览历史表")
@TableIndex(name = "user_artwork_index", fields = {"userId", "artworkId"})
public class BrowsingHistory extends BaseEntity {
    @ColumnComment("主键")
    @ColumnId(mode = IdType.AUTO)
    private Long id;

    @ColumnComment("用户ID")
    @ColumnNotNull
    @Index
    private String userId;

    @ColumnComment("作品ID")
    @ColumnNotNull
    @Index
    private String artworkId;
    
    @ColumnComment("浏览时长(秒)")
    @ColumnNotNull
    @ColumnDefault("0")
    private Integer duration;
    
    @ColumnComment("浏览次数")
    @ColumnNotNull
    @ColumnDefault("1")
    private Integer viewCount;

    @ColumnComment("最后浏览时间")
    @ColumnNotNull
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastViewTime;


}